package com.xy.springboot.game.common.data;

import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;
import com.iohao.game.widget.light.protobuf.ProtoFileMerge;
import com.xy.springboot.game.common.constant.SpringGameProtoFile;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.FieldDefaults;

@AllArgsConstructor
@NoArgsConstructor
@ToString
@ProtobufClass
@FieldDefaults(level = AccessLevel.PUBLIC)
@ProtoFileMerge(fileName = SpringGameProtoFile.COMMON_FILE_NAME, filePackage = SpringGameProtoFile.COMMON_FILE_PACKAGE)
public class ResultData<T>
{
    private static final int SUCCESS = 0;
    private static final int FAIL = 1;
    public int code;
    public String msg;
    public T data;
    public static ResultData success()
    {
        return new ResultData(SUCCESS, "ok", null);
    }
    public static <T> ResultData<T> success(T data)
    {
        return new ResultData<T>(SUCCESS, "ok", data);
    }
    public static ResultData fail(String msg)
    {
        return new ResultData(FAIL, msg, null);
    }
}
